package com.doone.telmarket.domain.factory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.doone.telmarket.domain.ServicePage;
import com.doone.telmarket.domain.SiteDirectory;
import com.doone.telmarket.domain.SiteResource;

/**
 * 
 * @author 吴同庆
 * @date 2009-9-17
 * @description 增值业务页面工厂
 * @package     com.doone.telmarket.domain.factory
 */
@Service
public class ServicePageFactory {
	
	@Autowired
	private SiteResourceFactory siteResourceFactory;
	
	private static final String SMALL_ICON = "small_icon";
	private static final String LOGO = "logo";
	
	
	public ServicePage createServicePage(com.doone.telmarket.domain.Service service,Integer recommandGrade,String serviceContent,
			String smallIconName,String logoName,String flashName)
	{
		String serviceCode = service.getServiceCode();
		String smllIconReplacmentName = this.concatName(SMALL_ICON, serviceCode);
		SiteResource smallIcon = siteResourceFactory.createSiteResource(smallIconName, smllIconReplacmentName
									, SiteDirectory.IMAGE_DIRECTORY,SiteDirectory.SERVICE_DIRECTORY);
		String logoReplacementName = this.concatName(LOGO, serviceCode);
		SiteResource logo = siteResourceFactory.createSiteResource(logoName, logoReplacementName, 
										SiteDirectory.IMAGE_DIRECTORY,SiteDirectory.SERVICE_DIRECTORY);
		SiteResource flash = siteResourceFactory.createSiteResource(flashName, serviceCode
										, SiteDirectory.FLASH_DIRECTORY,SiteDirectory.SERVICE_DIRECTORY);
		SiteResource page = siteResourceFactory.createSiteResource(serviceCode, SiteDirectory.PAGE_DIRECTORY,SiteDirectory.SERVICE_DIRECTORY);
		ServicePage servicePage = new ServicePage(service, recommandGrade, smallIcon, logo, flash, serviceContent, page);
		return servicePage;
	}
	
	
	private String concatName(String beforeName,String afterName){
		return beforeName.concat("_").concat(afterName);
	}
	

}
